package cn.lg.soar.mvc.converter;

import cn.lg.soar.common.util.DatetimeUtil;
import org.springframework.core.convert.converter.Converter;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * @author luguoxiang 469599794@qq.com
 * @Date: 2025/5/9 18:35
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public class LocalTimeConverter implements Converter<String, LocalTime> {

    private final DateTimeFormatter formatter;

    public LocalTimeConverter(DateTimeFormatter formatter) {
        this.formatter = formatter;
    }

    @Override
    public LocalTime convert(String source) {
        return DatetimeUtil.toLocalTime(source, formatter);
    }

}